package com.ysjr.anipluginsapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.ysjr.anipluginsapp.manager.PluginsManager;

import java.io.File;

public class MainActivity extends Activity {

    private TextView load;
    private TextView intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PluginsManager.getInstance().Attach(MainActivity.this);
        findView();
        initView();
    }

    private void findView() {
        load = findViewById(R.id.load);
        intent = findViewById(R.id.intent);
    }

    private void initView() {
        load.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                File file = new File(Environment.getExternalStorageDirectory(), "123.apk");
                PluginsManager.getInstance().loadPath(file.getAbsolutePath());
            }
        });
        intent.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ProxyActivity.class);
                intent.putExtra("className", PluginsManager.getInstance().getEntryActivityName());
                startActivity(intent);
            }
        });
    }

}
